package com.customer.controller.user;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.customer.entity.AICharacter;
import com.customer.result.Result;
import com.customer.service.AICharacterService;

/**
 * AI角色控制器
 */
@RestController
@RequestMapping("/user/ai/characters")
@Api(tags = "AI角色相关接口")
public class AICharacterController {
    
    @Autowired
    private AICharacterService aiCharacterService;
    
    /**
     * 获取角色列表
     */
    @GetMapping
    @ApiOperation("获取角色列表")
    public Result<List<AICharacter>> getAllPublicCharacters() {
        List<AICharacter> characters = aiCharacterService.getAllPublicCharacters();
        return Result.success(characters);
    }
    
    /**
     * 根据角色key获取角色详情
     */
    @GetMapping("/{roleKey}")
    @ApiOperation("根据角色key获取角色详情")
    public Result<AICharacter> getCharacterByRoleKey(@PathVariable String roleKey) {
        AICharacter character = aiCharacterService.getCharacterByRoleKey(roleKey);
        if (character == null) {
            return Result.error("角色不存在");
        }
        return Result.success(character);
    }
    
    /**
     * 搜索角色
     */
    @GetMapping("/search")
    @ApiOperation("搜索角色")
    public Result<List<AICharacter>> searchCharacters(String keyword) {
        List<AICharacter> characters = aiCharacterService.searchCharacters(keyword);
        return Result.success(characters);
    }
}